#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <assert.h>
#define N 128

int func(char* arr)
{
    int i = 0;
    int count = 0;
    while (arr[i] != '\n')
    {
        if (arr[i] == ' ')
        {
            i++;
            continue;
        }

        if (arr[i + 1] == ' ' || arr[i + 1] == '\n')
        {
            count++;
        }

        i++;

    }

    return count;
}


int main()
{
    char arr[N] = {0};
    printf("please input string:");
    char* tmp = fgets(arr, 127, stdin);
    assert(tmp);
    int ret = func(arr);
    printf("Have %d words\n", ret);
    return 0;
}
